package tests.create;

import static org.junit.Assert.fail;

import model.Budget;
import model.BudgetFactory;
import model.Line;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/*
 * 
 * Attempts to create a budget with a line
 * 
 */

public class LineCreateTest00
{
	Budget budget;
	BudgetFactory factory;
	Line line;

	@Before
	public void setUp() throws Exception
	{
		 factory = new BudgetFactory();
		 budget = (Budget) factory.create();
         budget.setName("Test budget");
         budget.setDescription("This is a test budget.");
	}

	@After
	public void tearDown() throws Exception
	{
		
	}

	@Test
	public void test()
	{
		 
		 try
         {
			 line = (Line) budget.createLine();
			 budget.add(line);
			 Boolean successful = budget.commit();
			 
			 if(!successful)
			 {
				fail("Could not create/add line");
			 }
			 else
			 {
				 System.out.println("Line commited. LineCreateTest00.java passed.");
			 }
         }
		 catch(Exception e)
		 {
			 fail("Line create failed with exception " + e);
		 }
	}
}